/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package SecretSanta.core;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author mrandell
 */
public class HistoryMap 
{
    public List<String> getAllSantaNames()
    {
        ArrayList<String> names = new ArrayList();
        for(int i = 0; i < mappings.size(); i++)
        {
            names.add(mappings.get(i).getSanta());
        }
        if (names.size() <= 0)
        {
            return null;
        }
        return names;
    }
    
    public String getSanta(String reciever)
    {
        for(Pair pair : mappings)
        {
            if(pair.getReciever().equals(reciever))
            {
                pair.getSanta();
            }
        }
        return null;
    }
    
    public String getReciever(String santa)
    {
        for(Pair pair : mappings)
        {
            if(pair.getSanta().equals(santa))
            {
                return pair.getReciever();
            }
        }
        return null;
    }
    
    public void removeSantaPairing(String santa){
        for(int i = 0; i < mappings.size(); i++)
        {
            if(mappings.get(i).getSanta().equals(santa))
            {
                mappings.remove(i);
            }
        }
    }
    
    public void clearMappings(){
        mappings.clear();
    }
    
    public void addPairing(Pair pair){
        mappings.add(pair);
    }
    
    public void addPairing(String santa, String reciever){
        
        this.addPairing(new Pair(santa, reciever));
    }

    public List<Pair> getMappings() {
        return mappings;
    }

    public void setMappings(List<Pair> mappings) {
        this.mappings = mappings;
    }

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }

    public HistoryMap(int year) {
        this.year = year;
        mappings = new ArrayList();
    }

    public HistoryMap(int year, List<Pair> mappings) {
        this.year = year;
        this.mappings = mappings;
    }
    int year;
    List<Pair> mappings;
}
